<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <button onclick="doAjax()">$.ajax(...)</button>
    <button onclick="doAjaxGet()">$.get(...)</button>
    <button onclick="doAjaxGetJson()">$.getJson(...)</button>
    <button onclick="doAjaxPost()">$.post(...)</button>
    <button onclick="doAjaxPostJson()">$.ajaxpostjson(...)</button>
    <button onclick="doAjaxLoad()">$("selecor").load(...)</button>
</div>
<div id="result"></div>
<script src="js/jquery.min.js"></script>
<script>
    function doAjaxLoad(){
        let url="http://localhost:1314/doGet"
        $("#result").load(url,function (){
            console.log("complete")
        })
    }
    function doAjaxPostJson(){
        let url="http://localhost:1314/doPostJson";
        let params={"id":"2","name":"huawei","letter":"h"}
        $.ajax({
            type: "post",
            url: url,
            contentType:"application/json;character=utf8",
            data:JSON.stringify(params),
            success:function (res){
                $("#result").html(res);
            }

        })
    }
    function doAjaxPost(){
        let url="http://localhost:1314/doPost";
        let params="id=1&name=xiaomi&letter=x";
        $.post(url,params,function (result){
            console.log(result);
        })
    }
    function doAjaxGetJson(){
    debugger
    let url="http://localhost:1314/doGet";
    let params="";
    $.get(url,params,function (result){
        console.log(result);
    },"json");
}
    function doAjaxGet(){
        debugger
        let url="http://localhost:1314/doGet";
        let params="";
        $.get(url,params,function (result){
            console.log(result);
        });
    }
    function doAjax(){
        debugger
        let url="http://localhost:1314/doAjax";
        let params="msg=hello jquery ajax";
        $.ajax({
            type:"GET",
            url:url,
            data:params,
            dataType:"text",
            async:true,
            success:function (result){
                $("#result").html(result);
            },
            error:function (){
                $("#result").html("request fail");
            }
        });
    }
</script>
</body>
</html>